#include <dirent.h>
#include <stdio.h>
#include <uuid/uuid.h>
#include <stdint.h>
#include <nit/list.h>
#include <nit/hset.h>
#include <nit/hmap.h>
#include "../bbu.h"

void
print(void *proc, Bbu_u *u)
{
	(void) proc;
	(void) u;

	return;
}

int
main(int argc, char *argv[])
{
	(void) argc;
	(void) argv;

	enum bbu_err err;
	Bbu_elist *args = NULL;
	Bbu_u *u = bbu_u_new("./dat.bbu/", &err);
	Bbu_f *ef = bbu_ef(NULL, print);
	Bbu_f *df = bbu_df(u, NULL, "./shared.so", "shared_print", 0, &err);
	Bbu_f *cf;

	bbu_u_add(u, ef);
	bbu_u_add(u, df);

	cf = bbu_cf(NULL,
		    bbu_elist_va(bbu_expr_fa(df->id, args),
				 bbu_expr_fa(ef->id, args),
				 NULL),
		    0);

	bbu_u_ser(u, df);
	bbu_u_ser(u, cf);

	bbu_u_add(u, cf);

	cf = bbu_u_deser(u, cf->id, &err);

	bbu_f_new_id(cf, NULL);
	bbu_u_ser(u, cf);

	bbu_u_add(u, cf);

	bbu_u_delete(u, cf->id);

	bbu_u_free(u);

	return 0;
}
